<!DOCTYPE html>

<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">

<title>module RubyXL::OOXMLObjectInstanceMethods - rubyXL 3.4.35</title>


  <meta name="keywords" content="ruby,module,RubyXL::OOXMLObjectInstanceMethods">


    <meta name="description" content="Documentation for the RubyXL::OOXMLObjectInstanceMethods module">





<script type="text/javascript">
  var rdoc_rel_prefix = "../";
  var index_rel_prefix = "../";
</script>

<script src="../js/navigation.js" defer></script>
<script src="../js/search.js" defer></script>
<script src="../js/search_index.js" defer></script>
<script src="../js/searcher.js" defer></script>
<script src="../js/darkfish.js" defer></script>

<link href="../css/fonts.css" rel="stylesheet">
<link href="../css/rdoc.css" rel="stylesheet">



<body id="top" role="document" class="module">
<div id="navigation-toggle" role="button" tabindex="0" aria-label="Toggle sidebar" aria-expanded="true" aria-controls="navigation">
  <span aria-hidden="true">&#9776;</span>
</div>


<nav id="navigation" role="navigation">
  <div id="project-navigation">
    <div id="home-section" role="region" title="Quick navigation" class="nav-section">
  <h2>
    <a href="../index.html" rel="home">Home</a>
  </h2>

  <div id="table-of-contents-navigation">
    <a href="../table_of_contents.html#pages">Pages</a>
    <a href="../table_of_contents.html#classes">Classes</a>
    <a href="../table_of_contents.html#methods">Methods</a>
  </div>
</div>

    <div id="search-section" role="search" class="project-section initially-hidden">
  <form action="#" method="get" accept-charset="utf-8">
    <div id="search-field-wrapper">
      <input id="search-field" role="combobox" aria-label="Search"
             aria-autocomplete="list" aria-controls="search-results"
             type="text" name="search" placeholder="Search (/) for a class, method, ..." spellcheck="false"
             title="Type to search, Up and Down to navigate, Enter to load">
    </div>

    <ul id="search-results" aria-label="Search Results"
        aria-busy="false" aria-expanded="false"
        aria-atomic="false" class="initially-hidden"></ul>
  </form>
</div>

  </div>

  

  

  

  

  
<div id="extends-section" class="nav-section">
  <h3>Extended With Modules</h3>

  <ul class="link-list">


    <li><a class="extend" href="OOXMLObjectClassMethods.html">RubyXL::OOXMLObjectClassMethods</a></li>


  </ul>
</div>


  
  <div class="nav-section">
    <h3>Class Methods</h3>
    <ul class="link-list" role="directory">

      <li ><a href="#method-c-included">included</a></li>

      <li ><a href="#method-c-new">new</a></li>

    </ul>
  </div>



  <div class="nav-section">
    <h3>Instance Methods</h3>
    <ul class="link-list" role="directory">

      <li ><a href="#method-i-3D-3D">==</a></li>

      <li ><a href="#method-i-before_write_xml">before_write_xml</a></li>

      <li ><a href="#method-i-get_node_object">get_node_object</a></li>

      <li ><a href="#method-i-index_in_collection">index_in_collection</a></li>

      <li ><a href="#method-i-init_child_nodes">init_child_nodes</a></li>

      <li ><a href="#method-i-write_xml">write_xml</a></li>

    </ul>
  </div>



  <footer id="validator-badges" role="contentinfo">
  <p><a href="https://validator.w3.org/check/referer">Validate</a></p>
  <p>Generated by <a href="https://ruby.github.io/rdoc/">RDoc</a> 6.15.1.</p>
  <p>Based on <a href="http://deveiate.org/projects/Darkfish-RDoc/">Darkfish</a> by <a href="http://deveiate.org">Michael Granger</a>.</p>
</footer>

</nav>

<main role="main" aria-labelledby="module-RubyXL::OOXMLObjectInstanceMethods">
  
  
    <ol role="navigation" aria-label="Breadcrumb navigation" class="breadcrumb">
      
      <li>
        
        <a href="../RubyXL.html">RubyXL</a><span>::</span>
        
      </li>
      
      <li>
        
        <span>OOXMLObjectInstanceMethods</span>
        
      </li>
      
    </ol>
  

  <h1 id="module-RubyXL::OOXMLObjectInstanceMethods" class="anchor-link module">
    module RubyXL::OOXMLObjectInstanceMethods
  </h1>

  <section class="description">
    
  </section>


  <section id="5Buntitled-5D" class="documentation-section anchor-link">







    <section class="attribute-method-details method-section">
      <header>
        <h3>Attributes</h3>
      </header>


      <div id="attribute-i-local_namespaces" class="method-detail anchor-link">
        <div class="method-heading attribute-method-heading">
          <a href="#attribute-i-local_namespaces" title="Link to this attribute">
            <span class="method-name">local_namespaces</span>
            <span class="attribute-access-type">[RW]</span>
          </a>
        </div>

        <div class="method-description">


        

        </div>
      </div>

    </section>



     <section id="public-class-5Buntitled-5D-method-details" class="method-section anchor-link">
       <header>
         <h3>Public Class Methods</h3>
       </header>


      <div id="method-c-included" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-c-included" title="Link to this method">
                <span class="method-name">included</span>
                <span class="method-args">(klass)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="included-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 222</span>
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier ruby-title">included</span>(<span class="ruby-identifier">klass</span>)
  <span class="ruby-identifier">klass</span>.<span class="ruby-identifier">extend</span> <span class="ruby-constant">RubyXL</span><span class="ruby-operator">::</span><span class="ruby-constant">OOXMLObjectClassMethods</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-c-new" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-c-new" title="Link to this method">
                <span class="method-name">new</span>
                <span class="method-args">(params = nil)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="new-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 231</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">initialize</span>(<span class="ruby-identifier">params</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-ivar">@local_namespaces</span> = <span class="ruby-keyword">nil</span>
  <span class="ruby-identifier">params</span> <span class="ruby-operator">||=</span> {}

  <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_attributes</span>).<span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">&quot;@#{v[:accessor]}&quot;</span>, <span class="ruby-identifier">params</span>[<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]]) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:computed</span>]
  }

  <span class="ruby-identifier">init_child_nodes</span>(<span class="ruby-identifier">params</span>)
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


    </section>

     <section id="public-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
       <header>
         <h3>Public Instance Methods</h3>
       </header>


      <div id="method-i-3D-3D" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-3D-3D" title="Link to this method">
                <span class="method-name">==</span>
                <span class="method-args">(other)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="3D-3D-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 260</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">==</span>(<span class="ruby-identifier">other</span>)
  <span class="ruby-identifier">other</span>.<span class="ruby-identifier">is_a?</span>(<span class="ruby-keyword">self</span>.<span class="ruby-identifier">class</span>) <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_attributes</span>).<span class="ruby-identifier">all?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]) <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]) } <span class="ruby-operator">&amp;&amp;</span>
    <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>).<span class="ruby-identifier">all?</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]) <span class="ruby-operator">==</span> <span class="ruby-identifier">other</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]) }
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-before_write_xml" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-before_write_xml" title="Link to this method">
                <span class="method-name">before_write_xml</span>
                <span class="method-args">()</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="before_write_xml-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 359</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">before_write_xml</span>
  <span class="ruby-comment">#TODO# This will go away once containers are fully implemented.</span>
  <span class="ruby-identifier">child_nodes</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>)
  <span class="ruby-identifier">child_nodes</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">_child_node_name</span>, <span class="ruby-identifier">child_node_params</span><span class="ruby-operator">|</span>
    <span class="ruby-keyword">self</span>.<span class="ruby-identifier">count</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:accessor</span>]).<span class="ruby-identifier">size</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:is_array</span>] <span class="ruby-operator">==</span> <span class="ruby-value">:with_count</span>
  }
  <span class="ruby-keyword">true</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          <p>Subclass provided filter to perform last-minute operations (cleanup, count, etc.) immediately prior to write, along with option to terminate the actual write if <code>false</code> is returned (for example, to avoid writing the collection’s root node if the collection is empty).</p>


        </div>





      </div>


      <div id="method-i-index_in_collection" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-index_in_collection" title="Link to this method">
                <span class="method-name">index_in_collection</span>
                <span class="method-args">()</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="index_in_collection-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 347</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">index_in_collection</span>
  <span class="ruby-keyword">nil</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          <p>Prototype method. For sparse collections (<code>Rows</code>, <code>Cells</code>, etc.) must return index at which this object is expected to reside in the collection. If <code>nil</code> is returned, then object is simply added to the end of the collection.</p>


        </div>





      </div>


      <div id="method-i-write_xml" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-write_xml" title="Link to this method">
                <span class="method-name">write_xml</span>
                <span class="method-args">(xml = nil, node_name_override = nil)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="write_xml-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 280</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">write_xml</span>(<span class="ruby-identifier">xml</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">node_name_override</span> = <span class="ruby-keyword">nil</span>)
  <span class="ruby-keyword">if</span> <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">then</span>
    <span class="ruby-identifier">seed_xml</span> = <span class="ruby-constant">Nokogiri</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span>(<span class="ruby-string">&#39;&lt;?xml version = &quot;1.0&quot; standalone =&quot;yes&quot;?&gt;&#39;</span>)
    <span class="ruby-identifier">seed_xml</span>.<span class="ruby-identifier">encoding</span> = <span class="ruby-string">&#39;UTF-8&#39;</span>

    <span class="ruby-keyword">if</span> <span class="ruby-constant">Nokogiri</span>.<span class="ruby-identifier">jruby?</span> <span class="ruby-keyword">then</span> <span class="ruby-comment"># Issue 188 workaround for JRuby</span>
      <span class="ruby-identifier">seed_xml</span>.<span class="ruby-identifier">to_java</span>.<span class="ruby-identifier">strict_error_checking</span> = <span class="ruby-keyword">false</span>
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">result</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">seed_xml</span>)
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">result</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">result</span> <span class="ruby-operator">==</span> <span class="ruby-string">&#39;&#39;</span>
    <span class="ruby-identifier">seed_xml</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">result</span>
    <span class="ruby-keyword">return</span> <span class="ruby-identifier">seed_xml</span>.<span class="ruby-identifier">to_xml</span>({ <span class="ruby-value">:indent</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-value">0</span>, <span class="ruby-value">:save_with</span> <span class="ruby-operator">=&gt;</span> <span class="ruby-constant">Nokogiri</span><span class="ruby-operator">::</span><span class="ruby-constant">XML</span><span class="ruby-operator">::</span><span class="ruby-constant">Node</span><span class="ruby-operator">::</span><span class="ruby-constant">SaveOptions</span><span class="ruby-operator">::</span><span class="ruby-constant">AS_XML</span> })
  <span class="ruby-keyword">end</span>

  <span class="ruby-keyword">return</span> <span class="ruby-string">&#39;&#39;</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">before_write_xml</span>

  <span class="ruby-identifier">attrs</span> = {}

  <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_attributes</span>).<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">k</span>, <span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">val</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>])

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">nil?</span> <span class="ruby-keyword">then</span>
      <span class="ruby-keyword">next</span> <span class="ruby-keyword">unless</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:required</span>]
      <span class="ruby-identifier">val</span> = <span class="ruby-identifier">v</span>[<span class="ruby-value">:default</span>]
    <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">val</span> = <span class="ruby-identifier">val</span> <span class="ruby-operator">&amp;&amp;</span>
            <span class="ruby-keyword">case</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:attr_type</span>]
            <span class="ruby-keyword">when</span> <span class="ruby-value">:bool</span>   <span class="ruby-keyword">then</span> <span class="ruby-identifier">val</span> <span class="ruby-operator">?</span> <span class="ruby-string">&#39;1&#39;</span> <span class="ruby-operator">:</span> <span class="ruby-string">&#39;0&#39;</span>
            <span class="ruby-keyword">when</span> <span class="ruby-value">:double</span> <span class="ruby-keyword">then</span> <span class="ruby-identifier">val</span>.<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">gsub</span>(<span class="ruby-regexp">/\.0*\Z/</span>, <span class="ruby-string">&#39;&#39;</span>) <span class="ruby-comment"># Trim trailing zeroes</span>
            <span class="ruby-keyword">else</span> <span class="ruby-identifier">val</span>
            <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">attrs</span>[<span class="ruby-identifier">k</span>] = <span class="ruby-identifier">val</span>
  }

  <span class="ruby-identifier">element_text</span> = <span class="ruby-identifier">attrs</span>.<span class="ruby-identifier">delete</span>(<span class="ruby-string">&#39;_&#39;</span>)
  <span class="ruby-identifier">elem</span> = <span class="ruby-identifier">xml</span>.<span class="ruby-identifier">create_element</span>(<span class="ruby-identifier">node_name_override</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_tag_name</span>), <span class="ruby-identifier">attrs</span>, <span class="ruby-identifier">element_text</span>)

  <span class="ruby-comment"># First, populate namespaces from the original document</span>
  <span class="ruby-ivar">@local_namespaces</span>&amp;.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">href</span>, <span class="ruby-identifier">prefix</span><span class="ruby-operator">|</span> <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">add_namespace_definition</span>(<span class="ruby-identifier">prefix</span>, <span class="ruby-identifier">href</span>) }

  <span class="ruby-comment"># Then, add defaults. Note that if some namespace prefix was already set, Nokogiri will NOT change that namespace.</span>
  <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_namespaces</span>).<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">href</span>, <span class="ruby-identifier">prefix</span><span class="ruby-operator">|</span> <span class="ruby-identifier">elem</span>.<span class="ruby-identifier">add_namespace_definition</span>(<span class="ruby-identifier">prefix</span>, <span class="ruby-identifier">href</span>) }

  <span class="ruby-identifier">child_nodes</span> = <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>)
  <span class="ruby-identifier">child_nodes</span>.<span class="ruby-identifier">each_pair</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">child_node_name</span>, <span class="ruby-identifier">child_node_params</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">node_obj</span> = <span class="ruby-identifier">get_node_object</span>(<span class="ruby-identifier">child_node_params</span>)
    <span class="ruby-keyword">next</span> <span class="ruby-keyword">if</span> <span class="ruby-identifier">node_obj</span>.<span class="ruby-identifier">nil?</span>

    <span class="ruby-keyword">if</span> <span class="ruby-identifier">node_obj</span>.<span class="ruby-identifier">respond_to?</span>(<span class="ruby-value">:write_xml</span>) <span class="ruby-operator">&amp;&amp;</span> <span class="ruby-operator">!</span><span class="ruby-identifier">node_obj</span>.<span class="ruby-identifier">equal?</span>(<span class="ruby-keyword">self</span>) <span class="ruby-keyword">then</span>
      <span class="ruby-comment"># If child node is either +OOXMLObject+, or +OOXMLContainerObject+ on its first (envelope) pass,</span>
      <span class="ruby-comment"># serialize that object.</span>
      <span class="ruby-identifier">elem</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">node_obj</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">child_node_name</span>)
    <span class="ruby-keyword">else</span>
      <span class="ruby-comment"># If child node is either vanilla +Array+, or +OOXMLContainerObject+ on its seconds (content) pass,</span>
      <span class="ruby-comment"># serialize its members.</span>
      <span class="ruby-identifier">node_obj</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">item</span><span class="ruby-operator">|</span> <span class="ruby-identifier">elem</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">xml</span>, <span class="ruby-identifier">child_node_name</span>) <span class="ruby-keyword">unless</span> <span class="ruby-identifier">item</span>.<span class="ruby-identifier">nil?</span> }
    <span class="ruby-keyword">end</span>
  }
  <span class="ruby-identifier">elem</span>
<span class="ruby-keyword">end</span></pre>
          </div>



          <p>Recursively write the OOXML object and all its children out as Nokogiri::XML. Immediately before the actual generation, +before_write_xml()+ is called to perform last-minute cleanup and validation operations; if it returns <code>false</code>, an empty string is returned (rather than <code>nil</code>, so Nokogiri::XML’s <code>&amp;lt;&amp;lt;</code> operator can be used without additional <code>nil</code> checking)</p>

<h3 id="method-i-write_xml-label-Parameters">Parameters<span><a href="#method-i-write_xml-label-Parameters">&para;</a> <a href="#top">&uarr;</a></span></h3>
<ul><li>
<p><code>xml</code> - Base Nokogiri::XML object used for building. If omitted, a blank document will be generated.</p>
</li><li>
<p><code>node_name_override</code> - if present, is used instead of the default element name for this object provided by <code>define_element_name</code></p>
</li></ul>

<h4 id="method-i-write_xml-label-Examples">Examples<span><a href="#method-i-write_xml-label-Examples">&para;</a> <a href="#top">&uarr;</a></span></h4>

<pre class="ruby"><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">write_xml</span>()
</pre>

<p>Creates a new empty <code>Nokogiri::XML</code>, populates it with the OOXML structure as described in the respective definition, and returns the resulting <code>Nokogiri::XML</code> object.</p>

<pre class="ruby"><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">seed_xml</span>)
</pre>

<p>Using the passed-in <code>Nokogiri</code> <code>xml</code> object, creates a new element corresponding to <code>obj</code> according to its definition, along with all its properties and children, and returns the newly created element.</p>

<pre class="ruby"><span class="ruby-identifier">obj</span>.<span class="ruby-identifier">write_xml</span>(<span class="ruby-identifier">seed_xml</span>, <span class="ruby-string">&#39;overriden_element_name&#39;</span>)
</pre>

<p>Same as above, but uses the passed-in <code>node_name_override</code> as the new element name, instead of its default name set by <code>define_element_name</code>.</p>


        </div>





      </div>


    </section>

     <section id="protected-instance-5Buntitled-5D-method-details" class="method-section anchor-link">
       <header>
         <h3>Protected Instance Methods</h3>
       </header>


      <div id="method-i-get_node_object" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-get_node_object" title="Link to this method">
                <span class="method-name">get_node_object</span>
                <span class="method-args">(child_node_params)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="get_node_object-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 351</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">get_node_object</span>(<span class="ruby-identifier">child_node_params</span>)
  <span class="ruby-keyword">self</span>.<span class="ruby-identifier">send</span>(<span class="ruby-identifier">child_node_params</span>[<span class="ruby-value">:accessor</span>])
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


      <div id="method-i-init_child_nodes" class="method-detail anchor-link ">
        <div class="method-header">

            <div class="method-heading">
              <a href="#method-i-init_child_nodes" title="Link to this method">
                <span class="method-name">init_child_nodes</span>
                <span class="method-args">(params)</span>
              </a>
            </div>

        </div>


          <div class="method-controls">
            <details class="method-source-toggle">
              <summary>Source</summary>
            </details>
          </div>



        <div class="method-description">

          <div class="method-source-code" id="init_child_nodes-source">
            <pre><span class="ruby-comment"># File lib/rubyXL/objects/ooxml_object.rb, line 242</span>
<span class="ruby-keyword">def</span> <span class="ruby-identifier ruby-title">init_child_nodes</span>(<span class="ruby-identifier">params</span>)
  <span class="ruby-identifier">obtain_class_variable</span>(<span class="ruby-value">:@@ooxml_child_nodes</span>).<span class="ruby-identifier">each_value</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">v</span><span class="ruby-operator">|</span>
    <span class="ruby-identifier">initial_value</span> =
      <span class="ruby-keyword">if</span> <span class="ruby-identifier">params</span>.<span class="ruby-identifier">has_key?</span>(<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]) <span class="ruby-keyword">then</span> <span class="ruby-identifier">params</span>[<span class="ruby-identifier">v</span>[<span class="ruby-value">:accessor</span>]]
      <span class="ruby-keyword">elsif</span> <span class="ruby-identifier">v</span>[<span class="ruby-value">:is_array</span>] <span class="ruby-keyword">then</span> []
      <span class="ruby-keyword">else</span> <span class="ruby-keyword">nil</span>
      <span class="ruby-keyword">end</span>

    <span class="ruby-identifier">instance_variable_set</span>(<span class="ruby-node">&quot;@#{v[:accessor]}&quot;</span>, <span class="ruby-identifier">initial_value</span>)
  }
<span class="ruby-keyword">end</span></pre>
          </div>



          


        </div>





      </div>


    </section>

  </section>

</main>
</body>

